<template>
  <el-row type="flex" class="row-bg" justify="center">
    <div class="title-container">
      <h3 class="title">欢迎使用浩泽管理软件平台</h3>
    </div>
    <el-col :xl="6" :lg="7">
      <el-card shadow="always" class="card">
        <el-form
          :model="registerForm"
          :rules="rules"
          ref="registerForm"
          label-width="80px"
          class="form_fa"
          @keyup.enter.native="submitForm('registerForm')"
        >
          <el-form-item label="用户名" prop="userName" style="width: 100%">
            <el-input v-model="registerForm.userName"></el-input>
          </el-form-item>
          <el-form-item label="密码" prop="password" style="width: 100%">
            <el-input
              v-model="registerForm.password"
              type="password"
            ></el-input>
          </el-form-item>

          <el-form-item>
            <el-button
              type="primary"
              @click="submitForm('registerForm')"
              style="width: 100%"
              >注册</el-button
            >
          </el-form-item>

          <el-form-item>
            <el-button type="primary" @click="ToLogin" style="width: 100%"
              >已经有账号，去登陆</el-button
            >
          </el-form-item>
        </el-form>
      </el-card>
    </el-col>
  </el-row>
</template>

<script>
import qs from "qs";

export default {
  name: "Login",
  data() {
    return {
      registerForm: {
        userName: "",
        password: "",
      },
      rules: {
        userName: [
          { required: true, message: "请输入用户名", trigger: "blur" },
        ],
        password: [{ required: true, message: "请输入密码", trigger: "blur" }],
      },
      captchaImg: undefined,
    };
  },
  created() {},
  methods: {
    ToLogin() {
      this.$router.push("/login");
    },
    submitForm() {
      this.$axios.post("/user/register", this.registerForm).then((res) => {
        console.log("resgiterForm", res);
        if (res.status) {
          this.$router.push({ path: "/login" });
        }
      });
      // this.$router.push("/login")
    },

    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
  },
};
</script>

<style scoped>
.form_fa >>> .el-form-item__label {
  color: #fff;
}

.el-button {
  width: 130px;
  height: 40px;
  font-size: 1em;
  font-weight: bold;
  background-color: #293140;
  border: 3px #3bb6f4 solid;
  margin: auto;
  color: #3bb6f4;
}

.el-button:hover {
  background-color: #156cd2;
  color: #fff;
}

.card {
  background-color: rgba(130, 187, 232, 0.1);
  border: none;
}

.title {
  font-size: 26px;
  color: white;
  margin: 0px 30px 40px 30px;
  text-align: center;
  font-weight: bold;
  display: inline-block;
}

.el-row {
  background-image: url("../assets/back.png");
  background-size: 100%;
  background-repeat: no-repeat;
  color: #fff;
  height: 100%;
  display: flex;
  align-items: center;
  text-align: center;
  justify-content: center;
}

.captchaImg {
  float: left;
  margin-left: 8px;
  border-radius: 4px;
}
</style>
